% ternary demo3
% ----------------------
% @author : slandarer
% 公众号  : slandarer随笔
% 知乎    : slandarer

figure('Name','ternary demo3','Units','normalized','Position',[.05,.2,.42,.56])

% 初始化三元相图(Init ternary plot)
STA=STernary();

% 随机构造数据(Randomly generated data)
A=rand(1,30);
B=rand(1,30);
C=rand(1,30);

% STA.SContourf(A,B,C,[],15,'LineWidth',1);

% 获取核密度范围并等分(Obtain the range of ksdensity and divide it equally)
[~,Z]=STA.SContourf(A,B,C,[],15,'Visible','off');
levels=linspace(.5,max(max(Z)),15);

% 依据等值线绘制等高线及等高线填充(Draw contour and contourf by levels)
CfHdl=STA.SContourf(A,B,C,[],levels,'LineWidth',1);
CHdl=STA.SContour(A,B,C,[],levels,'LineWidth',1,'EdgeColor',[0,0,0]);
SHdl=STA.SScatter(A,B,C,40,'filled','CData',[0,0,0]);

% 绘制图例(Draw legend)
legend([CfHdl,CHdl,SHdl],{'contourf','contour','scatter'},'FontSize',14,'FontName','Cambria')


colormap(turbo)
